package com.atguigu.dga.assessor.spec;

import com.atguigu.dga.assessor.Assessor;
import com.atguigu.dga.governance.bean.AssessParam;
import com.atguigu.dga.governance.bean.GovernanceAssessDetail;
import com.atguigu.dga.meta.constant.MetaConst;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;
@Component(value = "TEC_OWNER")
public class TecOwnerAssessor extends Assessor {
    @Override
    public void checkProblem(GovernanceAssessDetail governanceAssessDetail, AssessParam assessParam) {

        String tecOwnerUserName = assessParam.getTableMetaInfo().getTableMetaInfoExtra().getTecOwnerUserName();

        if (tecOwnerUserName == null || tecOwnerUserName.equals(MetaConst.TEC_OWNER_USER_NAME_UNSET)){
            //分数置零
            governanceAssessDetail.setAssessScore(BigDecimal.ZERO);
            //提示
            governanceAssessDetail.setAssessProblem("未设置技术负责人");
            //获取通用路径
            String governanceUrl = assessParam.getGovernanceMetric().getGovernanceUrl();
            //路径替换
            governanceUrl=governanceUrl.replace("{tableId}",assessParam.getTableMetaInfo().getId() + "");
            governanceAssessDetail.setGovernanceUrl(governanceUrl);
        }
    }
}
